<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>项目管理 <small></small></h2>
		        <div class="clearfix"></div>
	        </div>
			<div class="x_content">
				
				<div class="row">
					<ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
                        <li role="presentation" <#if isChecked=='0'>class="active"</#if>><a href="javascript:void(0);" id="home-tab" role="tab" data-toggle="tab" aria-expanded="true" onclick="selectQuery('','0');">待审核</a>
                        </li>
                        <li role="presentation" <#if isChecked=='1'>class="active"</#if>><a href="javascript:void(0);" role="tab" id="profile-tab" data-toggle="tab" aria-expanded="false" onclick="selectQuery('','1');">审核通过</a>
                        </li>
                        <li role="presentation" <#if isChecked=='2'>class="active"</#if>><a href="javascript:void(0);" role="tab" id="profile-tab2" data-toggle="tab" aria-expanded="false" onclick="selectQuery('','2');">审核不通过</a>
                        </li>
                      </ul>
<!-- 					<div class="col-sm-2"> -->
<!-- 					</div> -->
					<div class="col-sm-12">
						<div class="pull-left">
							<label><input type="text" id="projectName" value="${projectName!''}" class="form-control input-sm" placeholder="请输入项目名"></label>
							
<!--							<label>
								<select id="classifyId" name="classifyId" class="form-control select2">
		                        	<option value="">关键字</option>
		                        	<#list listClassify as classify>
		                        	<option value="${classify.id}" <#if (classifyId==classify.id?string.number)>selected="selected"</#if>>${classify.name}</option>
		                        	</#list>
	                    		</select>
	                    	</label>
							<label>
								<select id="areaProvince" name="areaProvince" class="form-control select2">
		                        	<option value="">所属省</option>
		                        	<#list listProvince as province>
		                        	<option value="${province.code}" <#if (projectProvince==province.code)>selected="selected"</#if>>${province.cityName}</option>
		                        	</#list>
	                    		</select>
	                    	</label>
	                    	<label>
								<select id="areaCity" name="areaCity" class="form-control select2">
		                        	<option value="">所属市</option>
		                        	<#list listCity as city>
		                        	<option value="${city.code}" <#if (projectCity==city.code)>selected="selected"</#if>>${city.cityName}</option>
		                        	</#list>
	                    		</select>
	                    	</label>
	                    	<label>
								<select id="areaDistrict" name="areaDistrict" class="form-control select2">
		                        	<option value="">所属区</option>
		                        	<#list listDistrict as district>
		                        	<option value="${district.code}" <#if (projectDistrict==district.code)>selected="selected"</#if>>${district.cityName}</option>
		                        	</#list>
	                    		</select>
	                    	</label>-->
							<button type="button" class="btn btn-dark" onclick="selectQuery('','${isChecked}');"><i class="fa fa-search"></i> 查询</button>
	<!--						<button type="button" class="btn btn-dark" onclick="toAdd();"><i class="fa fa-plus"></i> 新增</button>-->
						</div>
					</div>
				</div>
				<div class="table-responsive">
					<table class="table table-striped jambo_table bulk_action">
						<thead>
							<tr class="headings">
								<th class="column-title">项目名 </th>
								<th class="column-title">项目发起人 </th>
								<th class="column-title">封面图</th>
			                    <th class="column-title">审核时间 </th>
			                    <th class="column-title">审核人</th>
			                    <th class="column-title">创建时间</th>
			                    <th class="column-title">更新时间 </th>
			                    <th class="column-title no-link last"><span class="nobr">操作</span></th>
			                </tr>
						</thead>
			            <tbody>
			            	<#list page.content as obj>
			            	<tr class="even pointer">
			                    <td class=" ">${(obj.projectName)!'' }</td>
			                    <td class=" ">${(obj.user.userName)!''} </td>
			                    <td class=" "><img style="width:200px" src="${imagePath}${(obj.projectIcon)!''}"/> </td>
			                    <td class=" ">${(obj.checkTime)!''} </td>
			                    <td class=" ">${(obj.checkor)!''} </td>
			                    <td class=" ">${(obj.createTime)!''} </td>
			                    <td class=" ">${(obj.updateTime)!''} </td>
			                    <td class="last">
			                    <#if isChecked=="0">
			                    	<button type="button" class="btn btn-warning btn-xs" onclick="toCheck(${(obj.id)?c});"><i class="fa fa-edit"></i> 审核</button>
			                    </#if>
			                    <!--	<button type="button" class="btn btn-warning btn-xs" onclick="toEdit(${(obj.id)?c});"><i class="fa fa-edit"></i> 编辑</button>-->
			                    	<#if (obj.isDelete==0)>
			                    	<button type="button" class="btn btn-danger btn-xs" onclick="doDelete(${(obj.id)?c});"><i class="fa fa-close"></i> 删除</button>
			                    	</#if>
			                    	<#if (obj.isDelete==1)>
			                    	<button type="button" class="btn btn-warning btn-xs" onclick="doRecovery(${(obj.id)?c});"><i class="fa fa-repeat"></i> 恢复</button>
			                    	</#if>
			                    </td>
			                </tr>
			                </#list>
			            </tbody>
					</table>
				</div>
			</div>
			<#include "../common/paginator.ftl" />
		</div>
	</div>
</div>
<script type="text/javascript">
//select2
$(".select2").select2({width: "100px"});

$("#areaProvince").change(function(){
	$.post("${base}/common/getAreaList", {"pCode":$(this).val()}, function(data) {
		if (data.flag) {
			$("#areaCity").empty();
			$("#areaCity").append("<option value=''>所属市</option>");
			$.each(data.obj, function(i, n){
				$("#areaCity").append("<option value='"+n.code+"'>"+n.cityName+"</option>");
			});
		}
	});
});
$("#areaCity").change(function(){
	$.post("${base}/common/getAreaList", {"pCode":$(this).val()}, function(data) {
		if (data.flag) {
			$("#areaDistrict").empty();
			$("#areaDistrict").append("<option value=''>所属区县</option>");
			$.each(data.obj, function(i, n){
				$("#areaDistrict").append("<option value='"+n.code+"'>"+n.cityName+"</option>");
			});
		}
	});
});
/*进入添加*/
function toAdd(){
	$("#main_content").load('${base}/gx/project/toAdd');	
}

/*进入编辑*/
function toEdit(id){
	$("#main_content").load('${base}/gx/project/toEdit',{"id":id});	
}

/*进入审核*/
function toCheck(id){
	$("#main_content").load('${base}/gx/project/toCheck',{"id":id});	
}

/*删除*/
function doDelete(id){
	 swal({
		title: "删除",
		text: "您确定删除该资讯吗？",
		type: "warning",
		cancelButtonText:"取消",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		closeOnConfirm: false
	}, function(){
		$.post('${base}/gx/project/delete',{"id":id},function(data) {
			swal(data.msg);
			if (data.flag) {
				$("#main_content").load('${base}/gx/project/list');
			}
		});
	});
}

/*恢复*/
function doRecovery(id){
	 swal({
		title: "恢复",
		text: "您确定恢复该资讯吗？",
		type: "warning",
		cancelButtonText:"取消",
		showCancelButton: true,
		confirmButtonColor: "#DD6B55",
		confirmButtonText: "确定",
		closeOnConfirm: false
	}, function(){
		$.post('${base}/gx/project/recovery',{"id":id},function(data) {
			swal(data.msg);
			if (data.flag) {
				$("#main_content").load('${base}/gx/project/list');
			}
		});
	});
}

function selectQuery(pageIndex,isChecked){
	var data = {
		"pageIndex":pageIndex,
		//其余查询条件自行添加
		"isChecked":isChecked,
		"projectName":$.trim($("#projectName").val()),
		"moneyStart":$.trim($("#moneyStart").val()),
		"moneyEnd":$.trim($("#moneyEnd").val()),
		"classifyId":$.trim($("#classifyId").val()),
		"projectProvince":$.trim($("#areaProvince").val()),
		"projectCity":$.trim($("#areaCity").val()),
		"projectDistrict":$.trim($("#areaDistrict").val()),
	};
	$("#main_content").load('${base}/gx/project/list',data);	
}
</script>
